import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {

    public static boolean method(int num)
    {
        int s1=0,s2=1;
        while(true)
        {
            int s3=s1+s2;
            if(s3==num)
            {
                return true;
            }
            else if(s3>num)
            {
                return false;
            }
            s1=s2;s2=s3;
        }

    }

    public static int sum(int num)
    {
        if(num==0)
            return 0;
        int num1=num,num2=num,count=0,count1=0;
        while(num1>=0)
        {
            if(method(num1))
            {
                break;
            }
            num1--;
            count++;
        }
        while(num2>=0)
        {
            if(method(num2))
            {
                break;
            }
            num2++;
            count1++;
        }
        return Math.min(count,count1);
    }

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        int step=sum(num);
        System.out.println(step);
    }
}